package com.msteam.tools.code.generator.Property;

import java.util.Arrays;
import java.util.List;

import com.google.gson.Gson;
import com.msteam.tools.code.generator.Property.PropertyEnums.Aggregate;
import com.msteam.tools.code.generator.Property.PropertyEnums.AutoUpdateValue;
import com.msteam.tools.code.generator.Property.PropertyEnums.SearchOperator;
import com.msteam.tools.code.generator.Property.PropertyEnums.ViewTagType;
import com.msteam.tools.code.generator.Property.Column.DivViewTag;
import com.msteam.tools.code.generator.Property.Column.DropdownEditTag;
import com.msteam.tools.code.generator.Property.Column.HiddenEditTag;
import com.msteam.tools.code.generator.Property.Column.InputEditTag;
import com.msteam.tools.code.generator.Property.Column.TextAreaEditTag;
import com.msteam.tools.code.model.json.CbhColumnJson;

public class ColumnStruct
    {
        private String[] defaultHiddenFields = {
            "CREATE_DATE","create_date", "CreateDate",
            "CREATE_TIME", "CreateTime", "create_time",
            "modify_date","MODIFY_DATE","ModifyDate",
            "CREATOR","MODIFITOR","APPROVOR",
            "MODIFY_TIME","modify_time","ModifyTime",
            "APPROVE_TIME","approve_time","ApproveTime"};
        public ColumnStruct()
        {

        }
        public ColumnStruct(CbhColumnJson json)
        {
        	Gson gson = new Gson();
        	List<String> defaultHiddenFieldsArrayList = Arrays.asList(defaultHiddenFields);
            this.FieldName = json.getNAME();
            this.DataType = json.getTYPE();
            this.Size = json.getSIZE();
            this.Caption = json.getDISPLAY_NAME();
            this.PrimaryKey = json.getIS_PRIMARY_KEY();
            
            if (json.getIS_PRIMARY_KEY())
            {
                this.ViewTagType = ViewTagType.DIV;
                this.EditTagType = EditTagType.HIDDEN;
                this.EditTagJson = gson.toJson(new HiddenEditTag());
                this.ViewTagJson = gson.toJson(new DivViewTag());
            }
            else if (json.getTYPE().equalsIgnoreCase("TEXT"))
            {

                this.ViewTagType = ViewTagType.DIV;
                this.EditTagType = EditTagType.TEXTAREA;
                this.EditTagJson = gson.toJson(new TextAreaEditTag());
                this.ViewTagJson = gson.toJson(new DivViewTag());
            }
            else if(defaultHiddenFieldsArrayList.contains(json.getNAME()))
            {
                this.ViewTagType = ViewTagType.DIV;
                this.EditTagType = EditTagType.HIDDEN;
                this.EditTagJson = gson.toJson(new HiddenEditTag());
                this.ViewTagJson = gson.toJson(new DivViewTag());
            }else if (json.getNAME().endsWith("_ID") || json.getNAME().endsWith("_id"))
            {
                this.ViewTagType = ViewTagType.DIV;
                this.EditTagType = EditTagType.DROPDOWN;
                this.EditTagJson = gson.toJson(new DropdownEditTag());
                this.ViewTagJson = gson.toJson(new DivViewTag());
            }
            else
            {

                this.ViewTagType = ViewTagType.DIV;
                this.EditTagType = EditTagType.INPUT;
                this.EditTagJson = gson.toJson(new InputEditTag());
                this.ViewTagJson = gson.toJson(new DivViewTag());
            }


            this.setListPageExtSearch(false);
        }
        public String FieldName;
        public String DataType;
        public String Size;
        public String Caption;
        public Boolean PrimaryKey = false;
        public AutoUpdateValue AutoUpdateValue;
        public Boolean ListPageShow = false;
        public Boolean ListPageExport = false;

        public Aggregate ListPageAggregate;
        public String ListPageWidth;
        public Boolean ListPageQuickSearch = false;
        public Boolean ListPageExtSearch = false;


        public Boolean ViewPageShow = false;
        public Boolean EditPageShow = false;
        public String EditPageTitle;
        public Boolean EditPageReadOnly = false;

        public Boolean AddPageShow = false;
        public String AddPageDefaultValue;
        public Boolean MultiUpdate = false;


        public Boolean AdvanceSearch = false;
        public SearchOperator AdvanceSearchOpr1;
        public SearchOperator AdvanceSearchOpr2;
        public String AdvanceSearchDefaultValue1;
        public String AdvanceSearchDefaultValue2;

        public ViewTagType ViewTagType;
        public EditTagType EditTagType;
        public String ViewTagJson;
        public String EditTagJson;
        
        public Boolean QueryBy;
        public Boolean SortBy;
        
		public String[] getDefaultHiddenFields() {
			return defaultHiddenFields;
		}
		public void setDefaultHiddenFields(String[] defaultHiddenFields) {
			this.defaultHiddenFields = defaultHiddenFields;
		}
		public String getFieldName() {
			return FieldName;
		}
		public void setFieldName(String fieldName) {
			FieldName = fieldName;
		}
		public String getDataType() {
			return DataType;
		}
		public void setDataType(String dataType) {
			DataType = dataType;
		}
		public String getSize() {
			return Size;
		}
		public void setSize(String size) {
			Size = size;
		}
		public String getCaption() {
			return Caption;
		}
		public void setCaption(String caption) {
			Caption = caption;
		}
		public Boolean getPrimaryKey() {
			return PrimaryKey;
		}
		public void setPrimaryKey(Boolean primaryKey) {
			PrimaryKey = primaryKey;
		}
		public AutoUpdateValue getAutoUpdateValue() {
			return AutoUpdateValue;
		}
		public void setAutoUpdateValue(AutoUpdateValue autoUpdateValue) {
			AutoUpdateValue = autoUpdateValue;
		}
		public Boolean getListPageShow() {
			return ListPageShow;
		}
		public void setListPageShow(Boolean listPageShow) {
			ListPageShow = listPageShow;
		}
		public Boolean getListPageExport() {
			return ListPageExport;
		}
		public void setListPageExport(Boolean listPageExport) {
			ListPageExport = listPageExport;
		}
		public Aggregate getListPageAggregate() {
			return ListPageAggregate;
		}
		public void setListPageAggregate(Aggregate listPageAggregate) {
			ListPageAggregate = listPageAggregate;
		}
		public String getListPageWidth() {
			return ListPageWidth;
		}
		public void setListPageWidth(String listPageWidth) {
			ListPageWidth = listPageWidth;
		}
		public Boolean getListPageQuickSearch() {
			return ListPageQuickSearch;
		}
		public void setListPageQuickSearch(Boolean listPageQuickSearch) {
			ListPageQuickSearch = listPageQuickSearch;
		}
		public Boolean getListPageExtSearch() {
			return ListPageExtSearch;
		}
		public void setListPageExtSearch(Boolean listPageExtSearch) {
			ListPageExtSearch = listPageExtSearch;
		}
		public Boolean getViewPageShow() {
			return ViewPageShow;
		}
		public void setViewPageShow(Boolean viewPageShow) {
			ViewPageShow = viewPageShow;
		}
		public Boolean getEditPageShow() {
			return EditPageShow;
		}
		public void setEditPageShow(Boolean editPageShow) {
			EditPageShow = editPageShow;
		}
		public String getEditPageTitle() {
			return EditPageTitle;
		}
		public void setEditPageTitle(String editPageTitle) {
			EditPageTitle = editPageTitle;
		}
		public Boolean getEditPageReadOnly() {
			return EditPageReadOnly;
		}
		public void setEditPageReadOnly(Boolean editPageReadOnly) {
			EditPageReadOnly = editPageReadOnly;
		}
		public Boolean getAddPageShow() {
			return AddPageShow;
		}
		public void setAddPageShow(Boolean addPageShow) {
			AddPageShow = addPageShow;
		}
		public String getAddPageDefaultValue() {
			return AddPageDefaultValue;
		}
		public void setAddPageDefaultValue(String addPageDefaultValue) {
			AddPageDefaultValue = addPageDefaultValue;
		}
		public Boolean getMultiUpdate() {
			return MultiUpdate;
		}
		public void setMultiUpdate(Boolean multiUpdate) {
			MultiUpdate = multiUpdate;
		}
		public Boolean getAdvanceSearch() {
			return AdvanceSearch;
		}
		public void setAdvanceSearch(Boolean advanceSearch) {
			AdvanceSearch = advanceSearch;
		}
		public SearchOperator getAdvanceSearchOpr1() {
			return AdvanceSearchOpr1;
		}
		public void setAdvanceSearchOpr1(SearchOperator advanceSearchOpr1) {
			AdvanceSearchOpr1 = advanceSearchOpr1;
		}
		public SearchOperator getAdvanceSearchOpr2() {
			return AdvanceSearchOpr2;
		}
		public void setAdvanceSearchOpr2(SearchOperator advanceSearchOpr2) {
			AdvanceSearchOpr2 = advanceSearchOpr2;
		}
		public String getAdvanceSearchDefaultValue1() {
			return AdvanceSearchDefaultValue1;
		}
		public void setAdvanceSearchDefaultValue1(String advanceSearchDefaultValue1) {
			AdvanceSearchDefaultValue1 = advanceSearchDefaultValue1;
		}
		public String getAdvanceSearchDefaultValue2() {
			return AdvanceSearchDefaultValue2;
		}
		public void setAdvanceSearchDefaultValue2(String advanceSearchDefaultValue2) {
			AdvanceSearchDefaultValue2 = advanceSearchDefaultValue2;
		}
		public ViewTagType getViewTagType() {
			return ViewTagType;
		}
		public void setViewTagType(ViewTagType viewTagType) {
			ViewTagType = viewTagType;
		}
		public EditTagType getEditTagType() {
			return EditTagType;
		}
		public void setEditTagType(EditTagType editTagType) {
			EditTagType = editTagType;
		}
		public String getViewTagJson() {
			return ViewTagJson;
		}
		public void setViewTagJson(String viewTagJson) {
			ViewTagJson = viewTagJson;
		}
		public String getEditTagJson() {
			return EditTagJson;
		}
		public void setEditTagJson(String editTagJson) {
			EditTagJson = editTagJson;
		}
		public Boolean getQueryBy() {
			return QueryBy;
		}
		public void setQueryBy(Boolean queryBy) {
			QueryBy = queryBy;
		}
		public Boolean getSortBy() {
			return SortBy;
		}
		public void setSortBy(Boolean sortBy) {
			SortBy = sortBy;
		}
        
        
        
    }

